﻿using System;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HiTeachers.Web.Controls
{
    [ToolboxData("<{0}:LiteralStar runat=server></{0}:LiteralStar>")]
    public class LiteralStar : Literal
    {
        public object NumberStar
        {
            get { return (ViewState["NumberStar"] == null) ? (object)0 : (object)ViewState["NumberStar"]; }
            set { ViewState["NumberStar"] = value; }
        }

        protected override void OnPreRender(EventArgs e)
        {
            var startBuider = new StringBuilder();
            int numberStart = Convert.ToInt16(NumberStar);
            for (int i = 0; i < numberStart; i++) startBuider.Append("<img src=\"/images/star.gif\" alt=\"\" border=\"0\">");
            Text = startBuider.ToString();
        }
    }
}
